#!/bin/sh

# Simple shell-based filter. It is meant to be invoked as follows:
#       /path/to/script -f sender recipients...

# Localize these. The -G option does nothing before Postfix 2.3.
INSPECT_DIR="/var/proxytest"
SENDMAIL="/usr/sbin/sendmail"
PROXYTEST="/usr/local/bin/proxytest.py"

# Exit codes from <sysexits.h>
EX_TEMPFAIL=75
EX_UNAVAILABLE=69

# Clean up when done or when aborting.
trap "rm -f in.$$" 0 1 2 3 15

# Start processing.
cd $INSPECT_DIR || {
    echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }

cat >in.$$ || { 
    echo Cannot save mail to file; exit $EX_TEMPFAIL; }

# Specify your content filter here.
$PROXYTEST in.$$ $@

#if [ "$?" -eq 0 ]; then
#	echo "Sending"
#	$SENDMAIL "$@" <in.$$
#	exit $?
#fi

#$SENDMAIL "$@" <in.$$

exit 0

